package cn.ecnu.note.mapper;

import cn.ecnu.note.pojo.Reply;
import cn.ecnu.note.vo.ReplyVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ReplyMapper {

    @Select("SELECT COUNT(*) FROM reply WHERE comment_id = #{commentId} AND flag = 1")
    int getReplyCountByCommentId(Integer commentId);


    List<ReplyVo> getReplyVoByCommentId(@Param("commentId") Integer commentId, @Param("startNum") Integer startNum, @Param("pageSize") Integer pageSize);

    int insertReply(Reply reply);

    ReplyVo getReplyVoById(@Param("replyId") Integer replyId);

    @Select("SELECT * FROM reply WHERE reply_id = #{replyId} AND flag = 1")
    Reply getReplyById(@Param("replyId") Integer replyId);

    @Update("UPDATE reply SET flag = 0 WHERE reply_id = #{replyId}")
    int deleteReplyById(@Param("replyId") Integer replyId);
}
